package org.lemon.transport.context.utils;

import com.google.gson.Gson;
import org.lemon.transport.context.data.queue.message.ProtoQueueMessage;
import org.server.transport.gen.TransportProto;

import java.util.UUID;

public class Test {

    private static Gson gson = new Gson();

    public static void main(String[] args) {

        UUID uuid = UUID.fromString("38bb482f-9d3d-4e64-b999-b27954f63c7b");
        long lsb = uuid.getLeastSignificantBits();
        long msb = uuid.getMostSignificantBits();

        TransportProto.ToTransportMsg.Builder builder = TransportProto.ToTransportMsg.newBuilder();
        builder.setSessionIdLSB(lsb);
        builder.setSessionIdMSB(msb);
        TransportProto.AttributeUpdateNotificationMsg.Builder attUpdate = TransportProto.AttributeUpdateNotificationMsg.newBuilder();
        TransportProto.TsKeyValueProto kv = TransportProto.TsKeyValueProto.newBuilder()
                .setKv(TransportProto.KeyValueProto.newBuilder().setKey("ATT").setType(TransportProto.KeyValueType.STRING_V).setStringV("ni hao").build())
                .build();
        attUpdate.addSharedUpdated(kv);
        attUpdate.addSharedDeleted("1");
        builder.setAttributeUpdateNotification(attUpdate.build());
        TransportProto.ToTransportMsg transportMsg = builder.build();

        ProtoQueueMessage<TransportProto.ToTransportMsg> message = new ProtoQueueMessage<>(UUID.randomUUID(), transportMsg);
        System.out.println(gson.toJson(message).getBytes());
    }
}
